#define DEBUG
#include <cstdio>

using namespace std;

typedef long long ll;

const int maxn=100000;

void initMiu(int n, int miu[]) {
  static bool book[maxn+1];
  static int prime[maxn+1];
  book[1] = true, miu[1] = 1;
  for (int i=2; i<=n; i++) {
    if (!book[i]) {
      prime[++prime[0]] = i;
      miu[i] = -1;
    }
    for (int j=1; j<=prime[0] && i*prime[j]<=n && prime[j]<=i; j++) {
      book[i*prime[j]] = true;
      if (i%prime[j]) {
        miu[i*prime[j]] = -miu[i];
      } else {
        miu[i*prime[j]] = 0;
      }
    }
  }
}

void add(int x, int a[], int v) {
  for (int i=1; i*i<=x; i++) {
    if (x%i==0) {
      a[i]+=v;
      if (i*i!=x) {
        a[x/i]+=v;
      }
    }
  }
}

int count(int x, int cnt[], int miu[]) {
  int ret=0;
  for (int i=1; i*i<=x; i++) {
    if (x%i==0) {
      ret += cnt[i]*miu[i];
      if (i*i!=x) {
        ret += cnt[x/i]*miu[x/i];
      }
    }
  }
  return ret;
}

int main() {
  freopen("number.in", "r", stdin);
  freopen("number.out", "w", stdout);

  static int cnt[maxn+1], map[maxn+1], miu[maxn+1];
  int n, k;
  scanf("%d %d", &n, &k);
  initMiu(maxn, miu);

  ll ans=0;
  for (int i=1; i<=n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (b%k==0) {
      b /= k;
      if (a) {
        ans += count(b, cnt, miu);
        add(b, cnt, 1);
        map[b]++;
      } else {
        if (map[b]) {
          add(b, cnt, -1);
          ans -= count(b, cnt, miu);
          map[b]--;
        }
      }
    }
    printf("%lld\n", ans);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
